<template>
    <div class="EventBusSister">
        <p>事件总线使用案例：兄弟组件传值，Sister</p>
        <button @click="messageBrother" class="btn">给哥哥发消息</button>
        <div v-if="fromBrother" class="alert" v-html="fromBrother"></div>
    </div>
</template>
/* 使用事件总线，EventBusSister */
<script>
import { eventBus } from '../main.js'
export default {
    name: 'EventBusSister',
    data() {
        return {
            theCardTitle: "Sister Card",
            fromBrother: ""
        }
    },
    created() {
        eventBus.$on('brotherSaid', message => {
            // console.log('妹妹是否接收的到了消息', message)
            // console.log(this)
            this.fromBrother = message
        })
    },
    mounted() {
        
    },
    methods: {
        messageBrother() {
            eventBus.$emit("sisterSaid", "妈妈说，哥哥 该做作业了！(^_^)!!!");
        }
    },

}
</script>